class_name EmotesPanel
extends Panel


@onready var animated_sprite: AnimatedSprite2D = $Emote/AnimatedSprite2D
@onready var emote_idle_timer: Timer = $EmoteIdleTimer


var idle_emotes: Array[String] = ["emote_1_idle", "emote_2_smile", "emote_3_wave", "emote_4_blink"]


func _ready():
	animated_sprite.play(idle_emotes[0])

	InventoryManager.inventory_changed.connect(on_inventory_changed)
	GameDialogueManager.feed_the_animals.connect(on_feed_the_animals)


func play_emote(animation: String):
	animated_sprite.play(animation)


func _on_emote_idle_timer_timeout() -> void:
	var index = randi_range(0, idle_emotes.size() - 1)
	var emote = idle_emotes[index]

	animated_sprite.play(emote)


func on_inventory_changed():
	play_emote("emote_7_excited")


func on_feed_the_animals():
	play_emote("emote_6_love_kiss")